package com.bjpowernode.shop.pool;

import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/*
    商品导入的线程池
 */
public class ProductThreadPool {

    public static ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(
            // 核心线程数
            8,
            // 最大线程数
            Runtime.getRuntime().availableProcessors(),
            // 生命周期
            30,
            // 声明周期单位
            TimeUnit.SECONDS,
            // 处理任务的队列
            new LinkedBlockingQueue<>(20),
            // 默认的线程工厂
            Executors.defaultThreadFactory(),
            // 拒绝策略
            new ThreadPoolExecutor.AbortPolicy()
    );
}